<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.org/schema/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:tr="http://myfaces.apache.org/trinidad"
	template="layout/template.xhtml">

	<ui:define name="body">

      <tr:panelBox text="Artists" background="medium">
			<tr:form>
				<tr:inputText value="#{exampleArtist.name}" label="Filter by artist name">
					<f:ajax render="artists" event="keyup" requestDelay="1" />
				</tr:inputText>
				 &#160;
			</tr:form>

			<h:panelGroup id="artists">
				<tr:form>
					<tr:table value="#{artists.dataModel}" var="artist"
						rows="#{artists.maxResults}">
						<tr:column sortable="true" sortProperty="artist.name">
							<f:facet name="header">
	    				Name
	    			</f:facet>
							<s:link action="artist">
								<tr:outputText value="#{artist.name}" />
								<f:param name="artistId" value="#{artist.id}" />
							</s:link>
						</tr:column>
						<tr:column>
							<f:facet name="header">
	    				Band Members
	    			</f:facet>
							<tr:outputText value="Solo performer"
								rendered="#{artist.class.simpleName eq 'Artist'}" />
							<tr:outputText value="None"
								rendered="#{artist.class.simpleName eq 'Band' and empty artist.bandMembers}" />
                     <tr:group
                        rendered="#{artist.class.simpleName eq 'Band' and not empty artist.bandMembers}">
                        <ul>
                           <tr:iterator value="#{artist.bandMembers}" var="bandMember">
                              <li><tr:outputText value="#{bandMember.name}"/></li>
                           </tr:iterator>
                        </ul>
                     </tr:group>
						</tr:column>
						<f:facet name="detailStamp">
							<s:div style="width: 200px">
								<s:formattedText value="#{artist.description}"
									rendered="#{not empty artist.description}" />
								<tr:outputText value="None known"
									rendered="#{empty artist.description}" />
							</s:div>
						</f:facet>
					</tr:table>
				</tr:form>
			</h:panelGroup>
			<tr:panelButtonBar rendered="#{identity.loggedIn}">
				<s:button action="artist" value="Add artist" id="addArtist">
					<f:param name="artistId" value="" />
					<f:param name="type" value="artist" />
				</s:button>
				<s:button action="artist" value="Add band" id="addBand">
					<f:param name="artistId" value="" />
					<f:param name="type" value="band" />
				</s:button>
			</tr:panelButtonBar>
		</tr:panelBox>

	</ui:define>
</ui:composition>
